<?php

/*

Refer (refer.php)

*/

$page_title = "Referral Contest";
$rank_check = 0;
include "header.inc.php";

print "$openHTML";

$findReferralStatus = fetch("SELECT referrals,referrals2 FROM members_profiles2 WHERE username = '$username' AND game = '$game'");
$findTop10 = mysql_query("SELECT username,referrals2 FROM members_profiles2 WHERE game = '$game' ORDER BY referrals2 DESC LIMIT 0,10");
while ($getTop10 = mysql_fetch_array($findTop10))
{
	if (($getTop10[username] == "topwebgames") AND ($game == 1))
	{
		$getTop10[username] .= " (Not able to win!)";
	}
	$top10List .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=$base_url/user_profile.php?game=$game&user=$getTop10[username]>$getTop10[username]</a> ($getTop10[referrals2])<br>";
}

$findPage = fetch("SELECT * FROM game_pages WHERE page_title = '$page_title' AND game = '$game'");
if (!$findPage[id])
{
	print "<p>
Welcome to the referral contest, here you can get your referral link and check your referral status. Also, about once a week the top 10 referrers will win some awesome prizes! First place will get 50,000 $pointsVar! Second place gets 25,000 $pointsVar! Third place gets 12,500 $pointsVar! Also, some other prizes may be given away to the winners too!!
</p>";
}
else
{
	print "$findPage[page_info]";
}


ECHO <<<END
<center>
<P><TABLE BGCOLOR="$tableOutline" CELLSPACING=1 CELLPADDING=0 WIDTH="98%">
   <TR BGCOLOR="$topAndBottomBG">
      <TD WIDTH=100 HEIGHT=50>
         <CENTER class=white><FONT SIZE="+2" COLOR="$topAndBottomText"><B>--Referral
         Contest--</B></FONT></CENTER>
      </TD>
   </TR>
   <TR BGCOLOR="$reallyLight">
      <TD WIDTH=100 HEIGHT=20>
         <CENTER>Your referral link is:</CENTER>
      </TD>
   </TR>
   <TR BGCOLOR="$maincellColor">
      <TD WIDTH=100 HEIGHT=40>
         <CENTER><FONT COLOR="#FF0000"><B>$base_url/?game=$game&referer=$username</B></FONT></CENTER>
      </TD>
   </TR>
   <TR BGCOLOR="$reallyLight">
      <TD WIDTH=100>
         <CENTER>Feel free to give that link to all your friends,
         family, heck even strangers, just don't spam!</CENTER>
      </TD>
   </TR>
   <TR BGCOLOR="$maincellColor">
      <TD WIDTH=100>
         <P>You currently have <B>$findReferralStatus[referrals]</B> referrals.<B><BR>
         </B>You currently have $findReferralStatus[referrals2] referrals for the current
         contest.<BR>
         The top 10 referrers for this contest are:<BR>
         $top10List</P>
      </TD>
   </TR>
</TABLE>
</P>
</center>
END;

print "$closeHTML";
?>